load("//bzl:cpp_unittest.bzl", "cpp_unittest")

# NOTE: Test does not work with OSS distribution.
# cpp_unittest(
#     name = "arena_test",
#     srcs = ["ArenaTest.cpp"],
#     # labels = ["oss-broken"],
#     deps = [
#         "//folly:memory",
#         "//folly:random",
#         "//folly/memory:arena",
#         "//folly/memory:mallctl_helper",
#         "//folly/memory:malloc",
#         "//folly/portability:gflags",
#         "//folly/portability:gtest",
#         "@glog",
#     ],
# )

cpp_unittest(
    name = "mallctl_helper_test",
    srcs = ["MallctlHelperTest.cpp"],
    deps = [
        "//folly:c_portability",
        "//folly/init",
        "//folly/memory:mallctl_helper",
        "//folly/memory:malloc",
        "//folly/portability:gtest",
        "//folly/portability:sys_types",
        # TODO(kgk): Enable once @jemalloc is added to bcr. See:
        # https://github.com/bazelbuild/bazel-central-registry/issues/3757
        # "@jemalloc",
    ],
)

cpp_unittest(
    name = "malloc_test",
    srcs = ["MallocTest.cpp"],
    deps = [
        "//folly/memory:malloc",
        "//folly/portability:gtest",
        "//folly/portability:malloc",
        "//folly/test:test_utils",
    ],
)

cpp_unittest(
    name = "memory_resource_test",
    srcs = ["MemoryResourceTest.cpp"],
    deps = [
        "//folly/memory:memory_resource",
        "//folly/portability:gtest",
    ],
)

# NOTE: Test does not work with OSS distribution.
# cpp_unittest(
#     name = "not_null_test",
#     srcs = [
#         "not_null_test.cpp",
#     ],
#     # target_compatible_with = ["fbcode//opensource/macros:broken-in-oss"],
#     deps = [
#         "//folly/memory:not_null",
#         "//folly/portability:gtest",
#     ],
# )

cpp_unittest(
    name = "reentrant_allocator_test",
    srcs = ["ReentrantAllocatorTest.cpp"],
    deps = [
        "//folly:utility",
        "//folly/functional:invoke",
        "//folly/memory:reentrant_allocator",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "sanitize_address_test",
    srcs = ["SanitizeAddressTest.cpp"],
    deps = [
        "//folly/lang:new",
        "//folly/memory:sanitize_address",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "sanitize_leak_test",
    srcs = ["SanitizeLeakTest.cpp"],
    deps = [
        "//folly/memory:sanitize_leak",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "thread_cached_arena_test",
    srcs = ["ThreadCachedArenaTest.cpp"],
    deps = [
        "//folly:benchmark",
        "//folly:memory",
        "//folly:range",
        "//folly/lang:align",
        "//folly/memory:thread_cached_arena",
        "//folly/portability:gtest",
        "@glog",
    ],
)

cpp_unittest(
    name = "uninitialized_memory_hacks_test",
    srcs = [
        "UninitializedMemoryHacksODR.cpp",
        "UninitializedMemoryHacksTest.cpp",
    ],
    deps = [
        "//folly:random",
        "//folly/memory:uninitialized_memory_hacks",
        "//folly/portability:gtest",
        "@glog",
    ],
)
